//
//  ViewController.swift
//  eCLINICAL
//
//  Created by tom on 15/11/9.
//  Copyright © 2015年 tusm. All rights reserved.
//

import UIKit
import SwiftForms

class ViewController: FormViewController {
    
    struct ctrlTags {
        static let nameTag = "name"
        static let passwordTag = "password"
        var a = 0
    }

    @IBAction func btnClick(sender: AnyObject) {
        print("1")

    }
    
    func process()
    {
        NSThread.sleepForTimeInterval(3)
        LoadingView.shareInstance().hideView()
        SweetAlert().showAlert("i love china")
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
//        LoadingView.shareInstance().showInView(self.view)
//        LoadingView.shareInstance().showTitle("loading")
//        //NSThread.detachNewThreadSelector("process", toTarget: self, withObject: nil)
//        self.performSelector("process", onThread: NSThread.mainThread(), withObject: nil, waitUntilDone: false)
         LoadingView.shareInstance().showTitileAndProcess(ownerController: self, selector: "process")
    }
    
    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        self.loadformview()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    private func loadformview()
    {
        let form = FormDescriptor()
        
        form.title = "Example Form"
        
        let section1 = FormSectionDescriptor()
        
        var row: FormRowDescriptor! = FormRowDescriptor(tag: ctrlTags.nameTag, rowType: .Email, title: "Email")
        row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["textField.placeholder" : "john@gmail.com", "textField.textAlignment" : NSTextAlignment.Right.rawValue]
        section1.addRow(row)
        
        row = FormRowDescriptor(tag: ctrlTags.passwordTag, rowType: .Password, title: "Password")
        row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["textField.placeholder" : "Enter password", "textField.textAlignment" : NSTextAlignment.Right.rawValue]
        section1.addRow(row)
        form.sections = [section1]
        self.form = form
    }


}

